package monopoly;

import monopoly.ui.GameBoard;

public class GameState {
	
	private GameBoard gameBoard;
	private Player player1;
	private Player player2;
	private Die die1;
	private Die die2;
	private CardDeck chance;
	private CardDeck communityChest;
	
	public GameState()
	{
		this.gameBoard = null;
		this.player1 = null;
		this.player2 = null;
		this.die1 = null;
		this.die2 = null;
		this.chance = null;
		this.communityChest = null;
	}
	
	public GameState(GameBoard gameBoard, Player p1, Player p2, Die d1, Die d2, CardDeck chance, CardDeck communityChest)
	{
		this.gameBoard = gameBoard;
		this.player1 = p1;
		this.player2 = p2;
		this.die1 = d1;
		this.die2 = d2;
		this.chance = chance;
		this.communityChest = communityChest;
	}
	
	public GameBoard getGameBoard()
	{
		return gameBoard;
	}
	
	public Player getPlayer1()
	{
		return player1;
	}
	
	public Player getPlayer2()
	{
		return player2;
	}
	
	public Die getDie1()
	{
		return die1;
	}
	
	public Die getDie2()
	{
		return die2;
	}
	
	public CardDeck getChance()
	{
		return chance;
	}
	
	public CardDeck getCommunityChest()
	{
		return communityChest;
	}
	
	public Player getActivePlayer()
	{
		if (player1.getIsActive())
			return player1;
		else
			return player2;
	}
	
	public Player getInactivePlayer()
	{
		if (player1.getIsActive())
			return player2;
		else
			return player1;
	}
	
	public void switchPlayers()
	{
		Player activePlayer = this.getActivePlayer();
		activePlayer.resetRollCount();
		this.getInactivePlayer().makeActive();
		activePlayer.makeInactive();

	}

	public int getPlayerIndex() {
		if (player1.getIsActive())
			return 0; // if player 1 is active then its index is 0
		else
			return 1; // else its Player 2 who is active and its index is 1
	}

}
